//
//  EAThirstViewController.m
//  WhatToEat
//
//  Created by 方力 on 15/10/23.
//  Copyright (c) 2015年 Mac. All rights reserved.
//
#import "EADrinkingViewController.h"
#import "EAThirstViewController.h"

@interface EAThirstViewController ()
@property(nonatomic,strong)UIImageView * bgImageView;
@property(strong,nonatomic)UIButton * bt1;
@property(strong,nonatomic)UILabel * waterTipLabel;
@end

@implementation EAThirstViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    self.edgesForExtendedLayout=UIRectEdgeNone;
    self.extendedLayoutIncludesOpaqueBars=NO;
    self.automaticallyAdjustsScrollViewInsets=NO;
    self.navigationItem.title=@"口渴了";
    
    
    self.view.backgroundColor=[UIColor whiteColor];
    
    
    self.bgImageView=[[UIImageView alloc] initWithFrame:self.view.bounds];
    self.bgImageView.top=-44;
    [self.view addSubview:self.bgImageView];
    

    if ([Commtools isDaytime]) {
        
        self.bgImageView.image=[UIImage imageNamed:@"kl_bj"];
    }else
    {
       self.bgImageView.image=[UIImage imageNamed:@"kl_bj"];
    }
    

    
    
    
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"] style:0 target:self action:@selector(backAction:)];

    
    self.navigationController.navigationBar.tintColor=[UIColor whiteColor];
    
    
    
    

    
    [self updateUI];
    
}

-(void)viewWillAppear:(BOOL)animated
{

    [super viewWillAppear:animated];
    
    


}


-(void)updateUI
{

    UIImageView * weatherImageView=[[UIImageView alloc] initWithFrame:CGRectMake(kUI_SCREEN_WIDTH/3-10, 40, kUI_SCREEN_WIDTH/3+20, kUI_SCREEN_WIDTH/3+20)];
    
    weatherImageView.contentMode=UIViewContentModeScaleAspectFit;
    
    weatherImageView.image=[UIImage imageNamed:@"tianqi"];
    
    
    
    [self.view addSubview:weatherImageView];
    


    
    
    
    
    UIButton * bt1=[[UIButton alloc] initWithFrame:CGRectMake(0, kUI_SCREEN_WIDTH*2/3, kUI_SCREEN_WIDTH/2,44 )];
    
    [bt1 setImage:[UIImage imageNamed:@"yiban_2"] forState:0];
    
    [bt1 setImage:[UIImage imageNamed:@"yiban_1"] forState:UIControlStateSelected];
    [self.view addSubview:bt1];
    bt1.contentMode=UIViewContentModeScaleAspectFit;

    [bt1 addTarget:self action:@selector(actionsd:) forControlEvents:UIControlEventTouchUpInside];
    
    self.bt1=bt1;
    self.bt1.height=48;
    
    self.bt1.selected=YES;
    
    
    UIButton * bt2=[[UIButton alloc] initWithFrame:CGRectMake(kUI_SCREEN_WIDTH/2, kUI_SCREEN_WIDTH*2/3, kUI_SCREEN_WIDTH/2,44 )];
    [bt2 setImage:[UIImage imageNamed:@"jiaoke_1"] forState:UIControlStateSelected];
    [bt2 setImage:[UIImage imageNamed:@"jiaoke_2"] forState:0];
    [self.view addSubview:bt2];
    bt2.contentMode=UIViewContentModeScaleAspectFit;

    [bt2 addTarget:self action:@selector(actionsd:) forControlEvents:UIControlEventTouchUpInside];

    
    UILabel * l=[[UILabel alloc] initWithFrame:CGRectMake(15, bt2.bottom+10, kUI_SCREEN_WIDTH-30, 166)];
    [self.view addSubview:l];
    l.textColor=[UIColor whiteColor];
    l.numberOfLines=0;
    NSString *s=@"建议:每天最少饮水1200毫升，大约6杯的水量。如果活动量大，出汗多，则相应增加喝水量和及时补水。有人会问，之前一直说每天喝水不少于2000毫升也就是8杯水，为什么现在只有1200毫升？其实，2000毫升是指人一天需要的水分总量，果蔬里含有大量水分，连主食、肉里都有，人体需要的水，很大一部分来自于食物中。";

    l.attributedText=[Commtools attributedStringFromString:s];
    self.waterTipLabel=l;


    
    UIButton  * mybt1=[UIButton buttonWithType:UIButtonTypeCustom];
    
    mybt1.frame=CGRectMake(40, kUI_SCREEN_HEIGHT-180, 120, 50);
    [mybt1 setImage:[UIImage imageNamed:@"ysjl"] forState:0];
    [self.view addSubview:mybt1];
    

    [mybt1 addTarget:self action:@selector(todrinkingVC:) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    UIButton  * mybt2=[UIButton buttonWithType:UIButtonTypeCustom];
     mybt2.frame=CGRectMake(kUI_SCREEN_WIDTH-160, kUI_SCREEN_HEIGHT-180, 120, 50);
    [mybt2 setImage:[UIImage imageNamed:@"kqtx"] forState:0];
    [self.view addSubview:mybt2];
    [mybt2 addTarget:self action:@selector(todrinkingVC:) forControlEvents:UIControlEventTouchUpInside];
    
    
}

-(void)actionsd:(UIButton *)sender
{
 
    NSLog(@"%@",sender);
    
    sender.selected=!sender.selected;

    for (UIView *v in self.view.subviews) {
    
        if ([v isKindOfClass:[UIButton class]]) {
            
            
            if ([v isEqual:sender]) {
                
                v.height=48;
                
                
            }else
            {
            
                UIButton * b=(UIButton *)v;
                
                b.height=44;
                b.selected=!sender.selected;
            
            }
            
            
        }
        
    
    }
    
    
    if ([sender isEqual:self.bt1]) {
        NSString *s=@"建议:一般渴，每天最少饮水1200毫升，大约6杯的水量。如果活动量大，出汗多，则相应增加喝水量和及时补水。有人会问，之前一直说每天喝水不少于2000毫升也就是8杯水，为什么现在只有1200毫升？其实，2000毫升是指人一天需要的水分总量，果蔬里含有大量水分，连主食、肉里都有，人体需要的水，很大一部分来自于食物中。";
        
        self.waterTipLabel.attributedText=[Commtools attributedStringFromString:s];
    }else
    {
        NSString *s=@"建议:非常渴，每天最少饮水1600毫升，大约8杯的水量。如果活动量大，出汗多，则相应增加喝水量和及时补水。有人会问，之前一直说每天喝水不少于2000毫升也就是8杯水，为什么现在只有1200毫升？其实，2000毫升是指人一天需要的水分总量，果蔬里含有大量水分，连主食、肉里都有，人体需要的水，很大一部分来自于食物中。";
        
        self.waterTipLabel.attributedText=[Commtools attributedStringFromString:s];
    
    }
    
    

}

-(void)todrinkingVC:(UIButton * )bt
{
    EADrinkingViewController * dvc=[[EADrinkingViewController alloc] init];
    
    
    [self.navigationController pushViewController:dvc animated:YES];
    
    

}


-(void)backAction:(UIBarButtonItem *)bt
{


    [self.navigationController popViewControllerAnimated:YES];

}


@end
